﻿<?php 
	session_start();
	include "connect.php";  
	
	if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: gv-dangnhap.php");
	}
?>
<?php
	include("pChart/pData.class");
	include("pChart/pChart.class");
	function createChar($dt1,$dt2,$dt3,$dt4,$mamon)
	{
		// Dataset definition 
		 $DataSet = new pData;
		 $DataSet->AddPoint($dt1,"Serie1");
		 $DataSet->AddPoint($dt2,"Serie2");
		 $DataSet->AddPoint($dt3,"Serie3");
		 $DataSet->AddPoint($dt4,"Serie4");
		 $DataSet->AddAllSeries();
		 $DataSet->SetAbsciseLabelSerie();
		 $DataSet->SetSerieName("Khong hai long","Serie1");
		 $DataSet->SetSerieName("Hai long","Serie2");
		 $DataSet->SetSerieName("Rat hai long","Serie3");
		 $DataSet->SetSerieName("Xuat sac","Serie4");
		
		 // Initialise the graph
		 $Test = new pChart(850,300);
		 $Test->setFontProperties("Fonts/times_1.ttf",8);
		 $Test->setGraphArea(50,30,680,250);
		 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
		 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
		 $Test->drawGraphArea(255,255,255,TRUE);
		 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);
		 $Test->drawGrid(4,TRUE,230,230,230,50);
		
		 // Draw the 0 line
		 $Test->setFontProperties("Fonts/times_1.ttf",6);
		 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
		
		 // Draw the bar graph
		 $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,80);
		
		
		 // Finish the graph
		 $Test->setFontProperties("Fonts/times_1.ttf",13);
		 $Test->drawLegend(700,200,$DataSet->GetDataDescription(),255,255,255);
		 $Test->setFontProperties("Fonts/times_1.ttf",10);
		 $Test->drawTitle(50,22,$mamon,50,50,50,585);
		 $Test->Render("bieudo/image/".$mamon.".png");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kết Quả Đánh Giá</title>
<style type="text/css">

a	{
		color: #006600;
		text-decoration: none;
	}

a:hover { COLOR: #000099}

.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.style3 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style4 {
	color: #000099;
	font-weight: bold;
	font-size:20px;
}
.style5 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 30px;
}
.bg {	border-right-color:#0066FF;
		border-bottom-color:#0066FF;
	}

.bg1 {	border-bottom-color:#0066FF;}

.bg2 {	border-top-color:#0066FF;}

.bg3 {	border-left-color:#0066FF;}

.bg4 {	border-right-color:#0066FF;}
.mo	{	color:#0000FF;	}
.style6 {
	font-size: 22px;
	font-weight: bold;
	color: #000099;
}
.style7{
	font-size: 20px;
	font-weight: bold;
}
.style8 {
	font-size: 20px;
	color: #000099;
}
.cham { border-bottom-color:#666666;
		border-bottom-style:dotted;
		border-bottom-width:thin;	}
</style>
</head>

<body>

<?php
      $magv=$_SESSION['gv'];
	  $hknk=$_REQUEST["hk"];
	  $tam=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk' ");
	  $t=mysql_fetch_row($tam);
	  $hk=$t[1];$nk=$t[2];
	  $sql = mysql_query("Select a.ma_gv,a.ten_gv, a.namsinh_gv, a.gioitinh_gv, c.ten_khoa,d.ten_bm FROM `giang vien` a,  `khoa` c, `bo mon` d where a.ma_gv='$magv' and  a.ma_bm=d.ma_bm and d.ma_khoa=c.ma_khoa") ;		
		while($rows = mysql_fetch_array($sql))
		{
			$msgv=$rows["0"];
			$ten=$rows["1"];
			$namsinh=$rows["2"];
			$gioitinh=$rows["3"];
			$khoa=$rows["4"];
			$bomon=$rows["5"];
			
	    }
		$tam=mysql_query("select ma_hp,stt_nhom,sisolop_hp from `lop hoc phan` where ma_gv='$magv' and ma_hknk='$hknk'");
		$dem=0;$dem1=0;
		/*$k=mysql_query("select ma_sv from `danh gia` a,`lop hoc phan` b where ma_gv='$magv' and a.ma_hknk='$hknk' and a.ma_hp=b.ma_hp and a.stt_nhom=b.stt_nhom and a.ma_hknk=b.ma_hknk group by a.ma_hp,a.stt_nhom,a.ma_hknk,ma_sv");
		while($k1=mysql_fetch_row($k))
		{
		       $ma=$k1[0];
			   $dem++;
		}*/
?>
<table width="900" height="560" border="0" align="center" style="border:1px solid #CCCCCC">

<!-- đầu trang --> 	
	<tr> <td width="900" height="90" background="image/header.gif">
    	
        <table width="100%" height="100%" border="0"> 
          <tr>
       		
          <td width="10%" rowspan="2"><img src="image/logo.gif" width="100%" height="70" /></td>
            
            <td width="60%" rowspan="2" height="70" align="center" style="font-size:24px"><div align="center">
              <blockquote>
                <p><span class="style5">Website ĐÁNH GIÁ HỌC PHẦN</span></p>
              </blockquote>
          </div></td>
   		  	
          <td width="30%" valign="bottom"> <table>
       		  <tr><td valign="bottom">
           	  <div align="center" class="style3">
              	<a class="style3" href="trangchu.php">Hướng dẫn</a> | <a class="style3" href="gv-trangchu.php">Trang chủ</a> | <a class="style3" href="logout.php">Thoát</a></div></td></tr>
       	  	  <tr><td valign="bottom">
           	  <div align="center" class="style3">Xin chào, <?php echo $ten; ?> - <?php echo $msgv; ?></div></td></tr> 
   	  	  </table> </td>
        
        </tr> </table>
    
    </td> </tr>

	<tr> <td height="20" width="100%" bordercolor="#FFFFFF"></td> </tr>
	
<!--than trang -->	
	<form id="f" name="f" method="post" action="sv-themdanhgia.php">	
    <tr> <td valign="top" bordercolor="#FFFFFF">
    	
        <table width="900" align="center" cellspacing="0" border="0" style="border:1px solid #0066FF" cellpadding="0">
       		
      		<tr bordercolor="#FFFFFF"> 
           		<td align="center" height="100" class="bg1" colspan="5">
                	<span class="style6" style="font-size:30px">
					KẾT QUẢ NHẬN XÉT MÔN HỌC 
					
					<input type="hidden" name="ma" value="<?php echo $magv ?>" />
					<input type="hidden" name="hk" value="<?php echo $hknk; ?>;" />
					
					</span></td>
          	</tr>
                            

		   <?php
		           
					
					    
					
						while($t=mysql_fetch_row($tam))
						{
						        $mahp=$t[0];
								$stt=$t[1];
								$ss=$t[2];
								$khl=array();
						        $hl=array();
						        $rhl=array();
						        $xs=array();
								$k=mysql_query("select distinct (ma_sv) from `danh gia` where ma_hp='$mahp' and stt_nhom='$stt' and ma_hknk='$hknk'");
							
								while($k1=mysql_fetch_row($k))
										{
											   $ma=$k1[0];
											   $dem++;
										}
								$sql=mysql_query("select a.ma_tc,a.noidung_tc from `tieu chi` a, `tieuchi hocki` b where a.ma_tc=b.ma_tc and b.ma_hknk='$hknk' ");	
								while($row=mysql_fetch_row($sql))
								{
								   $matc=$row[0];
								   $sql1=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$mahp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='1' group by `muc danh gia`,ma_tc");
								   $sql2=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$mahp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='2' group by `muc danh gia`,ma_tc");
								   $sql3=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$mahp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='3' group by `muc danh gia`,ma_tc");
								   $sql4=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$mahp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='4' group by `muc danh gia`,ma_tc");
								   if(mysql_num_rows($sql1)==0) $muc1=0;
								   else
								   {
								   $r1=mysql_fetch_row($sql1);
								   $muc1=$r1[2];
								   }
								   if(mysql_num_rows($sql2)==0) $muc2=0;
								   else
								   {
								   $r2=mysql_fetch_row($sql2);
								   $muc2=$r2[2];
								   }
								   if(mysql_num_rows($sql3)==0) $muc3=0;
								   else
								   {
								   $r3=mysql_fetch_row($sql3);
								   $muc3=$r3[2];
								   }
								   if(mysql_num_rows($sql4)==0) $muc4=0;
								   else
								   {
								   $r4=mysql_fetch_row($sql4);
								   $muc4=$r4[2];
								   }
								               
												  if($dem==0) $dem1=1;
												  else $dem1=$dem;
														  $t=($muc1/$dem1)*100;
														  $t1=round($t,2);
														  $khl[]=$t1; 
														  $t2=($muc2/$dem1)*100;
														  $t3=round($t2,2);
														  $hl[]=$t3; 
														  $t4=($muc3/$dem1)*100;
														  $t5=round($t4,2);
														  $rhl[]=$t5; 
													
														  $t6=($muc4/$dem1)*100;
														  $t7=round($t6,2);
														  $xs[]=$t7; 
														  
														  
												   // echo $muc1.$muc2.$muc3.$muc4;
								   }//ngoac while(tieu chi)
								   ?>
								      
									  <tr  bordercolor="#FFFFFF" >
									        <td width="100">&nbsp;</td>
											<td  height="40" width="500" class="cham"><span class="style6">&nbsp;&nbsp;* Mã Số Lớp Học Phần:</span></td>
											<td   colspan="2" width="200" class="cham">
													  <span class="style6"><?php echo $mahp;echo $hknk;echo $stt; ?></span>				</td>
										    <td width="100">&nbsp;</td>
				
       	  	                         </tr>
									 <tr  bordercolor="#FFFFFF" >
									          <td width="150">&nbsp;</td>
											<td  height="40" class="cham"><span class="style7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Sĩ Số:</span></td>
											<td   colspan="2" class="cham">
													  <span class="style8"><?php echo $ss; ?></span>				</td>
											<td>&nbsp;</td>
				
       	  	                         </tr>
									 <tr  bordercolor="#FFFFFF" >
									          <td width="150">&nbsp;</td>
											<td  height="40" class="cham"><span class="style7">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Số Lượng Sinh Viên Tham Gia Đánh Giá:</span></td>
											<td   colspan="2" class="cham">
													  <span class="style8"><?php echo $dem; ?></span>				</td>
											<td>&nbsp;</td>
				
       	  	                         </tr>
						<tr>
						        <td colspan="4" style="font-weight:bold">
								          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(%)
								</td>
								<td >&nbsp;
								 
								</td>
						</tr> 	  
											<tr bordercolor="#FFFFFF">
													<td colspan="5" align="center">
														<!-- bieu do -->
														<!-- <script type="text/javascript" src="js/jsapi.js"></script>-->
														 <script type="text/javascript" src="http://www.google.com/jsapi"></script>
												<script type="text/javascript">
													/*google.load('visualization', '1', {'packages':['columnchart','piechart']});
										
												   
													google.setOnLoadCallback (createChart);
										
													
													function createChart() {
										
														var dataTable = new google.visualization.DataTable();
										
														dataTable.addColumn('string','Quarters');
														dataTable.addColumn('number', 'Không Hài Lòng');
														dataTable.addColumn('number', 'Hài Lòng');
														dataTable.addColumn('number', 'Rất Hài Lòng');
														dataTable.addColumn('number', 'Xuất Sắc');
										
														dataTable.addRows([
																			<?php
																				  //$solieu=array();
																				  ///for ($i=0;$i<11;$i++)
																				  //{
																					  // $solieu[]="['".($i+1)."',".$khl[$i].",".$hl[$i].",".$rhl[$i].",".$xs[$i]."]";
																				 /// } 
																				 // echo	  $solieu=implode(",",$solieu);
																			?>
																		]);
										
										
														var chart = new google.visualization.ColumnChart (document.getElementById('chart<?php //echo $mahp;echo $stt;?>'));
														
														
										
														var options = {width:800, height: 200, is3D: true, title: 'Biểu đồ Lớp Học Phần <?php //echo $mahp; echo $hknk;echo $stt; ?>'};
										
										
														chart.draw(dataTable, options);*/
													}
												</script>
														
														<!-- /bieu do -->
														<?php
														
															createChar($khl,$hl,$rhl,$xs,$mahp.$hknk.$stt);
															?>
														<img src="bieudo/image/<?php echo $mahp.$hknk.$stt.".png"; ?>" />
													</td>
											</tr>
											<tr>
													<td colspan="2" >&nbsp;
															  
													</td>
													<td style="font-weight:bold; font-size:16px" align="left" colspan="3">
													 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tiêu Chí
													</td>
						                   </tr> 
										   <tr>
													<td colspan="5" height="20">&nbsp;
													</td>
						                   </tr> 	   
											
		   <?php 
		                         
						$dem=0;$dem1=0;
									
						}//while 
					 
		   ?>
		  
		   
		  </table>
		  </td>
		  </tr>
    
</form>
	
<!--cuoi trang -->	
	<tr> <td height="5" width="100%" bordercolor="#FFFFFF"></td> </tr>

	<tr> <td height="28" background="image/footer.gif">
    	<table width="100%"> <tr >
    	
    	</tr> </table>
    </td> </tr>
</table>
</body>
</html>
﻿